<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAdvanceCardTransactionsTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('advance_card_transactions', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->comment('用户ID');
            $table->unsignedBigInteger('advance_card_id')->comment('垫付卡id');
            $table->unsignedBigInteger('order_id')->comment('拼单id');
            $table->decimal('amount', 10, 2)->default(0)->comment('保证金');
            $table->decimal('balance', 10, 2)->default(0)->comment('变动后保证金');
            $table->decimal('consume_beans', 10, 2)->default(0)->comment('消耗KC通证');
            $table->string('describe')->comment('描述');
            $table->tinyInteger('transaction_type')->default(0)->comment('1-充值, 2-使用');
            $table->tinyInteger('change_type')->default(1)->comment('1-增加, 2-减少');
            $table->tinyInteger('status')->default(1)->comment('1-处理中, 2-成功, 3-失败');
            $table->timestamps();
        });
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `advance_card_transactions` comment '垫付卡记录'");
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('advance_card_transactions');
    }
}
